package controllers

import (
	"github.com/astaxie/beego"
	"fmt"
	"wcy-xmt-api/models"
)

// 首页
type HomePageController struct {
	beego.Controller
}

// @Title 获取首页推荐列表
// @Description 推荐列表
// @Param app form int true "App编号"
// @Param size form int true "请求条目数"
// @Param current_page form int true "当前Page"
// @Success 200 {object} models.ResStatus
// @Success 200 {object} models.RecommendInfo
// @router /recommends [post]
func (this *HomePageController) Recommends() {
	fmt.Println("run HomePageController Recommends")
	resStatus := &models.ResStatus{}
	recommendInfo := &models.RecommendInfo{}
	recommendInfo.Code = 0
	recommendInfo.Message = ""

	recommends := []*models.Recommend{}
	recommend := &models.Recommend{}
	recommend.Id = 01
	recommend.Type = 1
	recommend.ArticleCategory = "文化"
	recommend.Time = "1小时前"
	recommend.ActiveNum = 121231
	recommend.Title = "小米5发布会"
	recommend.ImageUrl = "http://img4.3lian.com/sucai/img6/230/29.jpg"
	recommend.ContentUrl = "http://mp.weixin.qq.com/s?__biz=MjM5ODI3ODI4MA==&mid=419884212&idx=7&sn=8b409e74bf6eac486e535452d92a283f&3rd=MzA3MDU4NTYzMw==&scene=6#rd"
	recommend.GzhId = "sds121"
	recommend.GzhName = "宁波发布"
	recommend.IsCollect = 1
	recommend.IsPraise = 0
	recommends = append(recommends, recommend)

	recommend1 := &models.Recommend{}
	recommend1.Id = 02
	recommend1.Type = 2
	recommend1.ActiveNum = 121223
	recommend1.ChanId = 1232412
	recommend1.Title = "小米5发布会"
	recommend1.ImageUrl = "http://img4.3lian.com/sucai/img6/230/29.jpg"
	recommends = append(recommends, recommend1)

	recommend2 := &models.Recommend{}
	recommend2.Id = 03
	recommend2.Type = 3
	recommend2.ActiveNum = 121223
	recommend2.ChanId = 1232412
	recommend2.Title = "小米5发布会"
	recommend2.ImageUrl = "http://img4.3lian.com/sucai/img6/230/29.jpg"
	recommends = append(recommends, recommend2)

	recommend3 := &models.Recommend{}
	recommend3.Id = 04
	recommend3.Type = 4
	recommend3.ActiveNum = 12122123
	recommend3.ChanId = 123241223
	recommend3.Title = "小米5发布会"
	recommend3.ImageUrl = "http://img4.3lian.com/sucai/img6/230/29.jpg"
	recommends = append(recommends, recommend3)

	reds :=  &models.Recommends{}
	reds.CurPage = 0
	reds.Total = 10
	reds.Data = recommends

	recommendInfo.Recommends = reds

	resStatus.Code = 200
	resStatus.Data = recommendInfo
	resStatus.ErrMsg = "OK"

	this.Data["json"] = resStatus
	this.ServeJson()
}

// @Title 获取首页轮播图列表
// @Description 首页banner列表
// @Param app form int true "当前App编号"
// @Success 200 {object} models.ResStatus
// @Success 200 {object} models.BannerInfo
// @router /banners [post]
func (this *HomePageController) Banners() {
	fmt.Println("run HomePageController Banners")
	resStatus := &models.ResStatus{}
	bannerInfo := &models.BannerInfo{}
	bannerInfo.Code = 0
	bannerInfo.Message = ""

	banners := &models.Banners{}
	banners.CurPage = 1
	banners.Total = 10

	recommends := []*models.Recommend{}
	recommend := &models.Recommend{}
	recommend.Id = 01
	recommend.Type = 1
	recommend.ArticleCategory = "文化"
	recommend.Time = "1小时前"
	recommend.ActiveNum = 121231
	recommend.Title = "小米5发布会"
	recommend.ImageUrl = "http://img4.3lian.com/sucai/img6/230/29.jpg"
	recommend.ContentUrl = "http://mp.weixin.qq.com/s?__biz=MjM5ODI3ODI4MA==&mid=419884212&idx=7&sn=8b409e74bf6eac486e535452d92a283f&3rd=MzA3MDU4NTYzMw==&scene=6#rd"
	recommends = append(recommends, recommend)

	recommend1 := &models.Recommend{}
	recommend1.Id = 02
	recommend1.Type = 2
	recommend1.ActiveNum = 121223
	recommend1.ChanId = 1232412
	recommend1.Title = "小米5发布会"
	recommend1.ImageUrl = "http://img4.3lian.com/sucai/img6/230/29.jpg"
	recommends = append(recommends, recommend1)

	recommend2 := &models.Recommend{}
	recommend2.Id = 03
	recommend2.Type = 3
	recommend2.ActiveNum = 121223
	recommend2.ChanId = 1232412
	recommend2.Title = "小米5发布会"
	recommend2.ImageUrl = "http://img4.3lian.com/sucai/img6/230/29.jpg"
	recommends = append(recommends, recommend2)

	recommend3 := &models.Recommend{}
	recommend3.Id = 04
	recommend3.Type = 4
	recommend3.ActiveNum = 12122123
	recommend3.ChanId = 123241223
	recommend3.Title = "小米5发布会"
	recommend3.ImageUrl = "http://img4.3lian.com/sucai/img6/230/29.jpg"
	recommends = append(recommends, recommend3)

	banners.Data = recommends

	bannerInfo.Banners = banners

	resStatus.Code = 200
	resStatus.Data = bannerInfo
	resStatus.ErrMsg = "OK"

	this.Data["json"] = resStatus
	this.ServeJson()
}